home *** CD-ROM | disk | FTP | other *** search
/ All for Cell Phones: Sony Ericsson / Sony-Ericsson 2004.iso / Java / Bomba / Bomba.jar / Bomba$AnimationCanvas$CarsEngine.class (.txt) < prev    next >
Encoding:
Java Class File  |  2001-09-04  |  2.7 KB  |  83 lines

  1. import java.util.Random;
  2.  
  3. class Bomba$AnimationCanvas$CarsEngine {
  4.    // $FF: renamed from: w int
  5.    int field_0;
  6.    // $FF: renamed from: h int
  7.    int field_1;
  8.    long count;
  9.    Location[] vec;
  10.    Random random;
  11.    // $FF: synthetic field
  12.    private final Bomba$AnimationCanvas this$1;
  13.  
  14.    Bomba$AnimationCanvas$CarsEngine(Bomba$AnimationCanvas this$1) {
  15.       this.this$1 = this$1;
  16.       this.random = new Random();
  17.       this.vec = new Location[4];
  18.    }
  19.  
  20.    void init(int w, int h) {
  21.       this.count = 0L;
  22.       this.field_1 = h;
  23.       this.field_0 = w;
  24.       this.vec[0] = new Location(5, 0);
  25.       this.vec[1] = new Location(10, -30);
  26.       this.vec[2] = new Location(30, -h);
  27.       this.vec[3] = new Location(40, -2 * h / 3);
  28.    }
  29.  
  30.    void tick() {
  31.       ++this.count;
  32.       if (this.count % 50L == 0L && this.count < 5000L) {
  33.          --this.this$1.delay;
  34.          System.out.println("delay=" + this.this$1.delay);
  35.       }
  36.  
  37.       for(int i = 0; i < this.vec.length; ++i) {
  38.          this.vec[i].tick();
  39.       }
  40.  
  41.       for(int i = 0; i < this.vec.length; ++i) {
  42.          if (this.vec[i].y > this.field_1) {
  43.             Location temp = new Location();
  44.  
  45.             do {
  46.                temp.x = 2 + Math.abs(this.random.nextInt() % (this.field_0 - 14));
  47.                temp.y = -1 * Math.abs(this.random.nextInt() % (3 * this.field_1));
  48.             } while(!this.method_0(temp));
  49.  
  50.             System.out.println("### temp.x=" + temp.x + " temp.y=" + temp.y);
  51.  
  52.             for(int b = 0; b < this.vec.length; ++b) {
  53.                System.out.println("### vec[" + b + "]=" + this.vec[b].x + "," + this.vec[b].y);
  54.             }
  55.  
  56.             this.vec[i] = temp;
  57.          }
  58.       }
  59.  
  60.    }
  61.  
  62.    // $FF: renamed from: ok (Location) boolean
  63.    boolean method_0(Location temp) {
  64.       boolean result = true;
  65.  
  66.       for(int i = 0; i < this.vec.length && result; ++i) {
  67.          if ((temp.x <= this.vec[i].x && temp.x >= this.vec[i].x - 66 || temp.x >= this.vec[i].x && temp.x <= this.vec[i].x + 66) && (temp.y <= this.vec[i].y && temp.y >= this.vec[i].y - 66 || temp.y >= this.vec[i].y && temp.y <= this.vec[i].y + 66)) {
  68.             result = false;
  69.          }
  70.  
  71.          if (Math.abs(temp.y - this.vec[i].y) < 20) {
  72.             result = false;
  73.          }
  74.       }
  75.  
  76.       return result;
  77.    }
  78.  
  79.    Location[] getLocations() {
  80.       return this.vec;
  81.    }
  82. }
  83.